package com.link.base.base.expenseapplication.service;

import javax.annotation.Resource;

import com.link.base.base.expenseapplication.model.ApplicationStore;
import org.springframework.stereotype.Service;
import com.link.base.base.expenseapplication.dao.mybatis.mapper.ApplicationVerificationMapper;
import com.link.base.base.expenseapplication.model.ApplicationVerification;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.service.BasicServiceImpl;

import java.util.List;

/**
 * 费用申请-核销-费用申请-核销 
 *
 * @author 朱泊阳
 * @date 2019/05/05 15:29
 */
@Service
public class ApplicationVerificationServiceImpl extends BasicServiceImpl<ApplicationVerification> implements ApplicationVerificationService {

    @Resource
    private ApplicationVerificationMapper    applicationVerificationMapper;

    @Resource
    private ApplicationStoreService    applicationStoreService;
    
    @Override
    public BasicMapper<ApplicationVerification> getBasicMapper() {
        return applicationVerificationMapper;
    }

    @Override
    public List<ApplicationVerification> queryByExamplePage(ApplicationVerification entity) throws Exception {
        List<ApplicationVerification> tempList = applicationVerificationMapper.queryByExamplePage(entity);
        for (ApplicationVerification item : tempList) {
            ApplicationStore applicationStore = new ApplicationStore();
            applicationStore.setId(item.getApplicationNumber());
            applicationStore = applicationStoreService.queryById(applicationStore);
            item.setAccountAmount(applicationStore.getAccountAmount());
            item.setStoreName(applicationStore.getStoreName());
        }
        return tempList;
    }

    @Override
    public ApplicationVerification queryById(ApplicationVerification entity) throws Exception {
        ApplicationVerification applicationVerification = applicationVerificationMapper.queryById(entity);
        ApplicationStore applicationStore = new ApplicationStore();
        applicationStore.setId(applicationVerification.getApplicationNumber());
        applicationStore = applicationStoreService.queryById(applicationStore);
        applicationVerification.setAccountAmount(applicationStore.getAccountAmount());
        applicationVerification.setStoreName(applicationStore.getStoreName());
        return applicationVerification;
    }
}

